#ifndef QT_KNX_H
#define QT_KNX_H

#include "knx_interface.h"
#include "const_define.h"
#include "errcode.h"
#include "klog.h"
#include <QEventLoop>
#include <QCoreApplication>

typedef enum {
    KNX_IPR,
    KNX_IPS,
    TTG_IPS
}KNX_CONNECT_TYPE;

#define QT_IP_BYTE_3(ip)   (IP_BYTE_0(ip))
#define QT_IP_BYTE_2(ip)   (IP_BYTE_1(ip))
#define QT_IP_BYTE_1(ip)   (IP_BYTE_2(ip))
#define QT_IP_BYTE_0(ip)   (IP_BYTE_3(ip))

void processEvents(int execMsecs,int maxtime=100,QEventLoop::ProcessEventsFlags flags=QEventLoop::AllEvents);

void print_data(_string *title,void *src,_int32 len);

class DEVICE_OBJECT : public QObject
{
public:
    static QString KnxDataToQString(DATA_TYPE data_type,DATA_DEFINE value_define, unsigned char * buffer,int size);
    static int KnxQStringToData(QString value,DATA_TYPE data_type,DATA_DEFINE value_define,_u8 *buffer);
    static QByteArray getKnxBytesFromQString(QString value,DATA_TYPE data_type,DATA_DEFINE value_define);

    DATA_TYPE _data_type;
    DATA_DEFINE _data_define;
    void * _user_data;
    _u8 _ga_ia[EIB_DEVICE_ADDRESS_LEN];
    QByteArray _address;
    QString _name;
    QString _control;
};

#endif // QT_KNX_H
